/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved.
*
*  This file is part of the GroupMe! Project. Source code of 
*  this project is closed and redistribution of this code is
*  prohibited. 
*  
*  Contact: http://www.groupme.net
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.admin.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import net.groupme.admin.AdminManager;
import net.groupme.controller.model.HtmlFormattedElement;
import net.groupme.gui.constants.VIEW_VOCABULARY;

/**
 * created on Aug 2, 2007
 * 
 * This is an Ajax Controller for administration stuff..
 * 
 * @author Fabian Abel, <a href="mailto:abel@l3s.de">abel@l3s.de</a>
 * @author last edited by: $Author: fabian $
 * 
 * @version $Revision: 1.1 $ $Date: 2007-08-02 16:45:12 $
 */
public class AdminAjaxController implements ApplicationContextAware{

	/** Logger for this class and subclasses */
	protected final Log logger = LogFactory.getLog(getClass());
	/** the application context */
	private ApplicationContext applicationContext = null;
	
	/**
	 * Set the ApplicationContext that this object runs in. 
	 * @param applicationContext the current {@link ApplicationContext} 
	 */
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}

	//Hm, maybe this class is not needed if it would be possible to call AdminManger directly
	//(this would be difficult if some methods of AminManger hav complex Java Datatypes like User as input parameter)
	
	/**
	 * Recomputes the overall tag cloud and returns it as {@link HtmlFormattedElement}.
	 * @return the recomputed tag cloud as {@link HtmlFormattedElement}
	 */
	public HtmlFormattedElement computeOverallTagCloud(){
		AdminManager manager = (AdminManager) applicationContext.getBean(VIEW_VOCABULARY.ADMIN_MANGER, AdminManager.class);
		return manager.computeOverallTagCloud();
	}
	

}
